/*
 * @(#)ChceckLastAccessIntercepter.java $version 2013. 11. 29.
 *
 */

package com.pace.gonu.intercepter;

import java.util.Calendar;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.pace.gonu.model.chnl.PlayChannel;
import com.pace.gonu.play.PlayService;

/**
 * @author pace
 */
public class ChceckLastAccessIntercepter extends HandlerInterceptorAdapter {
	@Autowired
	private PlayService playService;


	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
		HttpSession session = request.getSession();
		Integer chnlNumber = (Integer)session.getAttribute("CHANNEL_NUMBER");
		PlayChannel playChannel = playService.getChannel(chnlNumber);

		playChannel.setLastAccessDate(Calendar.getInstance());
	}
}
